package com.danbay.cloud.account.service.api;

import com.danbay.cloud.account.dto.ContractDto;
import com.danbay.cloud.account.dto.ContractInfoDto;
import com.danbay.framework.exception.BusinessException;
import com.danbay.framework.springnc.annotation.AutoController;
import com.danbay.framework.springnc.annotation.RequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @author SJG
 *         2017/12/26.
 */
@AutoController
@RequestMapping("/account-service/contract")
@Api("合同操作接口")
public interface IContractService {

    /**
     * 检查合同号是否存在
     *
     * @param contractNum 合同号
     * @return 是否存在
     */
    @ApiOperation(value = "检查合同号是否存在")
    @RequestMapping(value = "/checkExists", method = RequestMethod.POST)
    void checkExists(@ApiParam("合同编号") String contractNum) throws BusinessException;

    /**
     * 添加合同号
     *
     * @param contract 合同号信息
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "添加新的合同号")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    void add(@RequestBody ContractDto contract) throws BusinessException;

    /**
     * 修改合同信息（有效期）
     *
     * @param contract 合同号信息
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "修改合同信息", notes = "只需修改合同有效期")
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    void edit( @RequestBody ContractDto contract) throws BusinessException;

    /**
     * 冻结合同
     *
     * @param num 合同号
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "冻结合同")
    @RequestMapping(value = "/freeze", method = RequestMethod.POST)
    void freeze(@ApiParam("合同号") String num) throws BusinessException;

    /**
     * 解冻合同
     *
     * @param num 合同号
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "解冻合同")
    @RequestMapping(value = "/unfreeze", method = RequestMethod.POST)
    void unfreeze(@ApiParam("合同号") String num) throws BusinessException;

    /**
     * 删除合同
     *
     * @param num 合同号
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "删除合同")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    void delete(@ApiParam("合同号") String num) throws BusinessException;

    /**
     * 删除企业下所有合同
     *
     * @param eid 企业id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "删除企业下所有合同")
    @RequestMapping(value = "/deleteByEid", method = RequestMethod.POST)
    void deleteByEid(@ApiParam("企业id") Integer eid) throws BusinessException;

    /**
     * 取企业下所有合同列表
     *
     * @param eid 企业id
     * @return 合同
     */
    @ApiOperation(value = "取企业下所有合同列表")
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    List<ContractInfoDto> all(@ApiParam("企业id") Integer eid);
}
